package com.xuecheng.content.feignclient;

import com.xuecheng.content.model.po.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/3/25 0:05
 */
@Component
@Slf4j
public class SearchServiceClientFallbacFactory implements FallbackFactory<SearchServiceClient> {

    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean add(CourseIndex courseIndex) {
                log.error("添加课程索引发生熔断，索引信息:{},熔断异常信息:{}", courseIndex, throwable);
                // 走降级了返回false
                return false;
            }
        };
    }
}
